package logic

import (
	"context"
	"errors"
	"user_srv/internal/dao"

	"user_srv/internal/svc"
	"user_srv/user"

	"github.com/zeromicro/go-zero/core/logx"
)

type CreateAchievementRuleLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewCreateAchievementRuleLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateAchievementRuleLogic {
	return &CreateAchievementRuleLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 个人成就规则添加
func (l *CreateAchievementRuleLogic) CreateAchievementRule(in *user.CreateAchievementRuleRequest) (*user.CreateAchievementRuleResponse, error) {
	// todo: add your logic here and delete this line
	rule, err := dao.CreateAchievementRule(in)
	if err != nil {
		return nil, errors.New("个人成就规则添加失败")
	}
	return &user.CreateAchievementRuleResponse{
		Id: int64(rule.Id),
	}, nil
}
